import { deleted, get, post, put } from "@/api/client";

/**
 * 退出登录
 * @returns {*}
 */
export function logout() {
	return get("/user/logout");
}

/**
 * 登录
 * @param user
 * @returns {*}
 */
export function login(user) {
	return post("/user/login", user);
}

/**
 * 修改密码
 * @param password
 * @returns {*}
 */
export function updatePassword(password) {
	return post("/user/updatePassword", password);
}

/**
 * 视频点赞
 * @param videoId 视频id
 * @returns {*}
 */
export function likeVideo(videoId) {
	return post("/videoLike", { videoId });
}

/**
 * 视频取消点赞
 * @param videoId
 * @returns {*}
 */
export function unLikeVideo(videoId) {
	return deleted("/videoLike", { videoId });
}

/**
 * 视频收藏
 * @param videoId
 * @returns {*}
 */
export function addCollection(videoId) {
	return post("/mycollection", { videoId });
}

/**
 * 视频取消收藏
 * @param videoId
 * @returns {*}
 */
export function unCollection(videoId) {
	return deleted("/mycollection", { videoId });
}

/**
 * 查询用户列表
 * @param {*} data
 * @returns
 */
export const getUserList = (data) => {
	return get("/user", data);
};

/**
 * 修改用户信息
 * @param {*} data
 * @returns
 */
export const updateUser = (data) => {
	return put("/user", data);
};

/**
 * 添加用户信息
 * @param {*} data
 * @returns
 */
export const addUser = (data) => {
	return post("/user/register", data);
};
/**
 * 添加用户信息
 * @param {*} data
 * @returns
 */
export const deletedUser = (data) => {
	return deleted("/user", data);
};

/**
 * 添加用户信息
 * @param  id
 * @returns
 */
export const getUserById = (id) => {
	return get(`/user/${id}`);
};
